package Script;

import interfaces.TextScriptArea;

import java.util.ArrayList;

public class JTextScriptArea implements TextScriptArea {
	private String text;
	private ArrayList<Integer> pointerList;
	
	public JTextScriptArea(String text) {
		this.text = text;
		
		/* Remove all tabs from it. */
		this.text = this.text.replaceAll("\\t","");
		
		pointerList = new ArrayList<Integer>();
	}
	
	/**
	 * Adds a pointer that points to the beginning of this
	 * text.
	 */
	public void addPointer(Integer pointer) {
		if (pointer != null) {
			pointerList.add(pointer);
		}
	}
	
	/**
	 * Returns this objects script text.
	 */
	public String getText() {
		return text;
	}
	
	/**
	 * Returns all pointers pointing to this text.
	 * Order not guaranteed.
	 */
	public ArrayList<Integer> getPointers() {
		return pointerList;
	}
	
	public String toString() {
		return text + " :: " + pointerList;
	}
}
